package com.lyb.spzx.user.service.impl;

import com.lyb.common.utils.AuthContextUtil;
import com.lyb.spzx.model.dto.system.system.user.UserAddress;
import com.lyb.spzx.user.mapper.UserAddressMapper;
import com.lyb.spzx.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserAddressServiceImpl implements UserAddressService {

    @Autowired
    UserAddressMapper userAddressMapper;

    @Override
    public List<UserAddress> findUserAddressList() {
        //获取用户ID
        Long userId = AuthContextUtil.getUserInfo().getId();
        List<UserAddress> userAddresses = userAddressMapper.selectByUserId(userId);
        return userAddresses;
    }

    @Override
    public UserAddress getUserAddressById(Long id) {
        UserAddress userAddress = userAddressMapper.selectUserAddressById(id);
        return userAddress;
    }
}
